<?=$this->header()?>


    <?=$this->menu("newsletters")?>


    <h1><?=$this->message("label.header", _Newsletter::BUNDLE)?></h1>


    <? /* Breadcrums route & newsletter info display */ ?>
    <?=$this->route(
        $this->message("label.header", _Newsletter::BUNDLE),      // Route display
        $this->newsletterListForm,                                // ListForm (for newsletter info, see float right)
        $this->newsletters($this->newsletterListForm)->getRows()) // The total amount of newsletters
    ?>


    <? /* Show status messages */ ?>
    <?=$this->messages(_Core::BUNDLE)?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null)?>


    <form id="<?=get_class($this->newsletterListForm)?>"
          method="post"
          action="newsletter/index"
          onsubmit="return confirmDelete('<?=$this->message("message.confirm.delete", _Core::BUNDLE)?>', this)">


        <? /* Show the Search & Filter Panel */ ?>
        <?=$this->panel(
            "newsletter/edit",         // Add New URL
            $this->newsletterListForm, // ListForm
            array(                     // Filter fields
                NewsletterPeer::SUBJECT=>$this->message("prompt.subject", _Newsletter::BUNDLE),
                NewsletterPeer::BODY=>$this->message("prompt.body", _Newsletter::BUNDLE),
                NewsletterPeer::SENT_DATE=>$this->message("label.sent", _Newsletter::BUNDLE),
                NewsletterPeer::INSERT_DATE=>$this->message("choose.created", _Core::BUNDLE),
                NewsletterPeer::MODIFIED_DATE=>$this->message("choose.modified", _Core::BUNDLE)
            ),
            false                      // No languages for this page.
        )?>


        <? /* Start output buffering in case there are no results */ ?>
        <?$this->start()?>


        <table class="list" cellspacing="0" cellpadding="0">
        <tr>
            <th class="checkbox"></th>
            <th>
                <?=$this->TH(
                    $this->newsletterListForm, // ListForm
                    NewsletterPeer::SUBJECT,   // Sort Field
                    $this->message("prompt.subject", _Newsletter::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->newsletterListForm,     // ListForm
                    NewsletterPeer::STATUS,        // Sort Field
                    $this->message("label.status", _Newsletter::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->newsletterListForm, // ListForm
                    NewsletterPeer::SENT_DATE, // Sort Field
                    $this->message("label.sent", _Newsletter::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->newsletterListForm,                     // ListForm
                    NewsletterPeer::MODIFIED_DATE,                 // Sort Field
                    $this->message("choose.modified", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="narrow">
                <?=$this->TH(
                    $this->newsletterListForm,                    // ListForm
                    NewsletterPeer::INSERT_DATE,                  // Sort Field
                    $this->message("choose.created", _Core::BUNDLE) // Header Name
                )?>
            </th>
            <th class="buttons"></th>
        </tr>

        <? foreach($this->newsletters($this->newsletterListForm)->getItems() as $newsletter) { ?>

            <? /* Display the default language newsletter */ ?>
            <tr class="ctrl">
                <td class="checkbox">

                    <input type="checkbox"
                           name="items[]"
                           value="<?=$newsletter->getNewsletterId()?>"
                           <?=in_array($newsletter->getNewsletterId(), $this->newsletterListForm->getItems()) ? " checked=\"checked\"" : ""?> />

                </td>
                <td><?=$this->truncateNicely($newsletter->getSubject(), 20, 28, "...")?></td>
                <td><?=$this->message("label.status.".$newsletter->getStatus(), _Newsletter::BUNDLE)?></td>
                <td title="Sent on: <?=$newsletter->getSentDate(_Core::FORMAT_DATETIME)?>">
                    <?=$newsletter->getSentDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.modified", _Core::BUNDLE)?> <?=$newsletter->getModifiedDate(_Core::FORMAT_DATETIME)?>">
                    <?=$newsletter->getModifiedDate(_Core::FORMAT_DATE)?>
                </td>
                <td title="<?=$this->message("title.created", _Core::BUNDLE)?> <?=$newsletter->getInsertDate(_Core::FORMAT_DATETIME)?>">
                    <?=$newsletter->getInsertDate(_Core::FORMAT_DATE)?>
                </td>
                <td class="buttons">

                    <input type="button"
                           onclick="to('newsletter/recipients?id=<?=$newsletter->getNewsletterId()?>')"
                           class="button"
                           value="<?=$this->message("label.send", _Newsletter::BUNDLE)?>" />

                    <input type="button"
                           onclick="to('newsletter/edit?newsletter->newsletterId=<?=$newsletter->getNewsletterId()?>')"
                           class="button"
                           value="<?=$this->message("button.edit", _Core::BUNDLE)?>" />

                    <input type="button"
                           onclick="del(<?=$newsletter->getNewsletterId()?>, '<?=get_class($this->newsletterListForm)?>')"
                           class="button"
                           value="<?=$this->message("button.delete", _Core::BUNDLE)?>" />

                </td>
            </tr>

        <? } ?>

        </table>


        <? /* Edit/Action Bar for checkboxed */ ?>
        <?=$this->edit(
            $this->newsletterListForm, // ListForm
            array(                     // The actions
                "delete"=>$this->message("choose.delete", _Core::BUNDLE)
            )
        )?>


        <? /* End output buffering */ ?>
        <?$this->end(
            $this->newsletterListForm,                               // ListForm
            $this->path()."newsletter/edit",                         // Add New URL
            $this->newsletters($this->newsletterListForm)->getRows() // The total amount of newsletters
        )?>


    </form>

<?=$this->footer()?>